package com.woniu.atms.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.atms.entity.G5Passenger;
import com.woniu.atms.entity.G5TicketSite;
import com.woniu.atms.mapper.G5PassengerDao;
import com.woniu.atms.mapper.G5TicketSiteDao;
import com.woniu.atms.service.G5TicketSiteService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;

/**
 * (G5TicketSite)表服务实现类
 *
 * @author makejava
 * @since 2022-01-19 15:01:09
 */
@Service("g5TicketSiteService")
public class G5TicketSiteServiceImpl extends ServiceImpl<G5TicketSiteDao, G5TicketSite> implements G5TicketSiteService {
    @Resource
    private G5TicketSiteDao g5TicketSiteDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public G5TicketSite queryById(Integer id) {
        return this.g5TicketSiteDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param g5TicketSite 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<G5TicketSite> queryByPage(G5TicketSite g5TicketSite, PageRequest pageRequest) {
        long total = this.g5TicketSiteDao.count(g5TicketSite);
        return new PageImpl<>(this.g5TicketSiteDao.queryAllByLimit(g5TicketSite, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param g5TicketSite 实例对象
     * @return 实例对象
     */
    @Override
    public G5TicketSite insert(G5TicketSite g5TicketSite) {
        this.g5TicketSiteDao.insert(g5TicketSite);
        return g5TicketSite;
    }

    /**
     * 修改数据
     *
     * @param g5TicketSite 实例对象
     * @return 实例对象
     */
    @Override
    public G5TicketSite update(G5TicketSite g5TicketSite) {
        this.g5TicketSiteDao.update(g5TicketSite);
        return this.queryById(g5TicketSite.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.g5TicketSiteDao.deleteById(id) > 0;
    }
}
